package top.kaoshanji.q1ch07a;

import top.kaoshanji.y1constant.FileConstant;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;

/**
 * 代码清单-q1ch07a-329页b：格式化的内存输入
 * 无法用返回值检测输入是否结束
 * author kaoshanji
 * ^_^
 * create time 2025/3/12 15:24
 */
public class FormattedMemoryInput {

    static String pathStr = FileConstant.LOCAL_ROOT_PATH.concat("q1ch07a329页b\\");

    public static void main(String[] args) {

        try (DataInputStream in = new DataInputStream(
                new ByteArrayInputStream(
                        BufferedInputFile.read(pathStr.concat("FormattedMemoryInput.java")).getBytes()))) {

            while (true) {
                System.out.println((char) in.readByte());
            }

        } catch(EOFException e) {
            System.out.println("\nEnd of stream");
        } catch(IOException e) {
            throw new RuntimeException(e);
        }


    }


}
